<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
</head>
<body>
	<script>
	// 页面加载后，就缓存10条数据，大于10条自动删除，里面的数据可以随时调用。
	function cc(){
		var data=[];
		var hc = {};
		var max = 10;
		function cache(name,val){
			if(data.length>max){
				var de = data.shift();
			}
			data.push(name);
			hc[name] = val;
			delete hc[de];
			// console.log(hc);
			return hc
		}
		return cache;
	}
	var c = cc()
	var arr1 = [];
	var arr2 = [];
	for(var i=0;i<10;i++){
		arr1[i] = 'name'+i;
		arr2[i] = 'yijun'+i;
	}
	for(var j=0;j<arr1.length;j++){
		c(arr1[j],arr2[j])
	}
	//获取数据
	console.log(c().name1)
	</script>
</body>
</html>